<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>录像回放</title>
  <style>
    input,button {
      width: 500px;height: 37.5px;font-size: 18px;margin-top: 15px;
    }
  </style>
</head>

<body>
  <!-- 通过CDN直接引入flvjs -->
  <script src="../src/js/mpegts.js"></script>
  <div style="text-align: center;">
    <video id="videoElement" style="width: 800px;height: 600px;" controls>
    </video>
    <br>
    <input type="text" value="http://192.168.1.15:8080/flv/100_2.flv" id="flv_src" placeholder="请输入flv地址">
    <br>
    <button onclick="play()">播放</button>
  </div>
  <script>

    let videoElement = document.getElementById('videoElement');
    let flvEl = document.getElementById('flv_src')
    // flvEl.value = "http://192.168.1.250:10101/lal_record/flv/3-1706086087.flv"
    // http://192.168.1.196:10101/lal_record/mpegts/r_1-1707200587.ts

    if (mpegts.getFeatureList().mseLivePlayback) {
      function play() {
        let player = mpegts.createPlayer({
          type: 'flv',  // could also be mpegts, m2ts, flv
          isLive: true,
          url: flvEl.value
        });
      
        player.attachMediaElement(videoElement);
        player.load();
      
        console.log("点击播放")
        player.play().catch(err => {
          console.log("播放异常", err)
        })
      }

    }else {
      console.log("不支持mpegts");
    }


    // let pullUrl = 'http://192.168.1.250:10101/lal_record/flv/task_1-1706078894.flv'

    

  </script>
</body>

</html>